<?php
namespace Mob\Model;
use Think\Model;

class UserModel extends Model
{
	 public function getUserByMobile($mobile)
	{
		$condition["mobile"] = $mobile;
		$user = $this->where($condition)->select();
		return $user;
	}
	
	public function getUserByEmail($email)
	{
	    $condition["email"] = $email;
	    $user = $this->where($condition)->select();
	    return $user;
	}
	
	public function getUserByPasswd($Uid,$paswd)
	{
	    $condition["mobile"] = $Uid;
	    $condition['email'] = $Uid;
	    $condition['id'] = $Uid;
	    $condition['_logic'] = 'OR';
	    $map['_complex'] = $condition;
	    $map['loginpasswd'] = md5($paswd);
	    $user = $this->where($map)->select();
	    return $user;
	}
	
	public function updateLoginDate($uid,$from) {
	    // 要修改的数据对象属性赋值
	    $data['id'] = $uid;
	    $data['logindate'] = date("Y-m-d H:i:s ");
	    $this->save($data); // 根据条件保存修改的数据
	    
	    $ipadr = get_client_ip();
	    $Ip = new \Org\Net\IpLocation('UTFWry.dat');
	    $area = $Ip->getlocation($ipadr);
	    $userOperalog=D('UserOperalog');
	    $userOperalog->uid=$uid;
	    $userOperalog->operation=1;
	    $userOperalog->ip=$ipadr;
	    $userOperalog->city=$area;
	    if($from==null){
	       $userOperalog->client_type=1;
	    }
	    $userOperalog->createdate=date("Y-m-d H:i:s ");
	    $userOperalog->add();
	}
	/**
	 * 修改密码
	 * @param unknown $uid
	 * @param unknown $paswd
	 */
	public function updatePaswd($uid,$paswd) {
	    // 要修改的数据对象属性赋值
	    $data['id'] = $uid;
	    $data['loginpasswd'] = md5($paswd);
	    $this->save($data); // 根据条件保存修改的数据
	}
}
?>